package com.wypiwyl.footastic.view;

import com.wypiwyl.footastic.Direction;

import android.graphics.Point;
import android.graphics.Rect;

public class LayoutUtil {

    public static Rect getCenterLayout(Point position, int width, int height) {
        return new Rect(position.x - (width / 2), position.y - (height / 2), position.x + (width / 2), position.y + (height / 2));
    }

    public static Rect getDirectionLayout(Point position, Direction direction, int width, int height) {

        int left = 0;
        int top = 0;
        int right = 0;
        int bottom = 0;

        switch (direction) {
            case NORTH:
                left = position.x;
                top = position.y - height;
                right = position.x + width;
                bottom = position.y;
            break;
            case NORTH_EAST:
                left = position.x;
                top = position.y - height;
                right = position.x + width;
                bottom = position.y;
            break;
            case EAST:
                left = position.x;
                top = position.y;
                right = position.x + width;
                bottom = position.y + height;
            break;
            case SOUTH_EAST:
                left = position.x;
                top = position.y;
                right = position.x + width;
                bottom = position.y + height;
            break;
            case SOUTH:
                left = position.x - width;
                top = position.y;
                right = position.x;
                bottom = position.y + height;
            break;
            case SOUTH_WEST:
                left = position.x - width;
                top = position.y;
                right = position.x;
                bottom = position.y + height;
            break;
            case WEST:
                left = position.x - width;
                top = position.y - height;
                right = position.x;
                bottom = position.y;
            break;
            case NORTH_WEST:
                left = position.x - width;
                top = position.y - height;
                right = position.x;
                bottom = position.y;
            break;
        }

        return new Rect(left, top, right, bottom);
    }
}
